package com.evil.application.pojo.dto.form.control.code;

import com.alibaba.fastjson.JSON;
import com.evil.application.pojo.dto.form.control.code.config.TableRelatedConfigDTO;
import com.evil.application.pojo.entity.ApplicationFormControl;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.NoArgsConstructor;
import org.apache.commons.lang3.StringUtils;

/**
 * 表格控件-表单控件实体
 *
 * @author liyang
 * @date 2022-08-08 00:00
 */
@Data
@NoArgsConstructor
@EqualsAndHashCode(callSuper = true)
public class TableControlDTO extends ControlDTO {

    public static final String[] ignoreProperties = new String[]{"tableRelatedConfig"};

    /**
     * 表格关联配置
     */
    private TableRelatedConfigDTO tableRelatedConfig;

    public TableControlDTO(ApplicationFormControl applicationFormControl) {
        super(applicationFormControl, ignoreProperties);
        this.tableRelatedConfig = new TableRelatedConfigDTO();
        if (StringUtils.isNotBlank(applicationFormControl.getTableRelatedConfig())) {
            this.tableRelatedConfig = JSON.parseObject(applicationFormControl.getTableRelatedConfig(), TableRelatedConfigDTO.class);
        }
    }
}
